
#include <iostream>
#include <vector>
#include <string>
using namespace std;

class Solution 
{
public:
    int m = 0, n = 0;
    vector<vector<char>> copy;
    int dx[4] = { -1, 1, 0, 0 };
    int dy[4] = { 0, 0, -1, 1 };
    int solve(vector<vector<char>>& grid)
    {
        if (1 == grid.size() && grid[0].empty())
            return 0;

        int res = 0;
        copy = grid;
        m = grid.size(), n = grid[0].size();
        vector<vector<bool>> vis(m, vector<bool>(n, false));

        for (int i = 0; i < m; ++i)
        {
            for (int j = 0; j < n; ++j)
            {
                if ('1' == copy[i][j])
                {
                    ++res;
                    _bfs(copy, vis, i, j);
                }
            }
        }

        return res;
    }

    void _bfs(vector<vector<char> >& copy, vector<vector<bool> >& vis, int i, int j)
    {
        copy[i][j] = '0';
        vis[i][j] = true;

        for (int k = 0; k < 4; ++k)
        {
            int x = i + dx[k], y = j + dy[k];
            if (x >= 0 && x < m && y >= 0 && y < n && '1' == copy[x][y] && !vis[x][y])
                _bfs(copy, vis, x, y);
        }
    }

};

void Test1()
{
    string s;
    cin >> s;

    int n = s.size();
    int pos = 0, len = 0;

    for (int beg = 0, end = 0; beg < n;)
    {
        if (isdigit(s[beg]))
        {
            for (end = beg + 1; end < n && isdigit(s[end]); ++end);
            if (end - beg > len)
            {
                len = end - beg;
                pos = beg;
            }
            beg = end + 1;
        }
        else
        {
            ++beg;
        }
    }

    cout << s.substr(pos, len) << endl;

}

bool check(int a, int b, int c)
{
    if (a + b <= c || a + c <= b || b + c <= a)
        return false;
    if (a - b >= c || b - a >= c || a - c >= b || c - a >= b || b - c >= a || c - b >= a)
        return false;
    return true;
}

void Test2()
{
    int n = 0;
    cin >> n;

    vector<int> v(6);

    while (n--)
    {
        for (int i = 0; i < 6; ++i)
        {
            cin >> v[i];
        }

        int flag = 0;
        for (int i = 0; i < 6; ++i)
        {
            for (int j = 0; j < 6; ++j)
            {
                for (int k = 0; k < 6; ++k)
                {
                    if (i != j && i != k && j != k)
                    {
                        int a1 = v[i], b1 = v[j], c1 = v[k];
                        int a2 = 0, b2 = 0, c2 = 0;
                        for (int c = 0; c < 6; ++c)
                        {
                            if (c != i && c != j && c != k)
                            {
                                if (0 == a2)
                                {
                                    a2 = v[c];
                                    continue;
                                }
                                if (0 == b2)
                                {
                                    b2 = v[c];
                                    continue;
                                }
                                    
                                if (0 == c2)
                                {
                                    c2 = v[c];
                                    continue;
                                }
                            }
                        }
                        if (check(a1, b1, c1) && check(a2, b2, c2))
                        {
                            cout << "Yes" << endl;
                            flag = 1;
                            break;
                        }
                    }
                }
                if (flag)
                    break;
            }
            if (flag)
                break;
        }

        if (0 == flag)
            cout << "No" << endl;
    }
}

int main()
{
    Test1();
    Test2();

	return 0;
}